<?php
class qos{
	private $sites = array(
		array('qiyi','DX00000042','奇艺','vod'),
		array('letv','DX00000046','乐视','vod'),
	);
	private function GetTxt($url){
		$str = file_get_contents($url);
		preg_match_all("/\<tr[^\>]*\>\s*\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>.*?\<td\>(\d*)\<\/td\>/ims",$str,$matches);
		for($i=0;$i<count($matches[1]);$i++){
			$matches[11][$i] = $matches[6][$i]/$matches[5][$i]*100;
			$matches[12][$i] = $matches[9][$i]/$matches[5][$i]*100;
		}
		return $matches;
	}
	public function proc(){
		foreach($this->sites as $site){
			$r = $this->GetTxt("http://192.168.1.236:811/test/demo.html");
			$r["title"] = $site[2];
			$this->createFile($r,"tpl/MSLine.php","/data/webroot/mwall/public/iface/".$site[3]."/1/".$site[1].".xml");
			$this->createFile($r,"tpl/MSLine1.php","/data/webroot/mwall/public/iface/".$site[3]."/2/".$site[1].".xml");
		}
		//$r = $this->GetTxt("http://192.168.1.236:811/test/demo.html");
		//$this->createFile($r);
	}
	private function createFile($result,$s_fname="MSLine.php",$o_fname = "xxx.xml"){
		ob_end_clean();   
		ob_start();   
		include($s_fname);   
		$length = ob_get_length();   
		$buffer = ob_get_contents();   
		ob_end_clean();    
		$fp = fopen($o_fname,"w+");   
		fwrite($fp,$buffer);   
		fclose($fp);
	}
}
$qos = new qos();
$qos->proc();
#$result = $qos->GetTxt("http://192.168.1.236:811/test/demo.html");
#include("MSLine.php");
